﻿using System;
using System.Windows.Data;
using System.Windows.Media;
using AutoLoL.Entities;

namespace AutoLoL.Converters
{
    public class MasteryToColorConverter : IMultiValueConverter
    {
        private static Color Black = Color.FromArgb(0xFF, 0x00, 0x00, 0x00);
        private static Color Gray = Color.FromArgb(0xFF, 0xAA, 0xAA, 0xAA);
        private static Color Orange = Color.FromArgb(0xFF, 0xFF, 0xD1, 0x00);
        private static Color Green = Color.FromArgb(0xFF, 0x1A, 0xFF, 0x1A);

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Color result = Black;
            
            if (values.Length == 2)
            {
                MasteryValue mastery = values[0] as MasteryValue;
                if (mastery != null)
                {
                    if (mastery.CurrentRank == 0)
                        result = Gray;
                    else if (mastery.CurrentRank == mastery.MaximumRank)
                        result = Orange;
                    else
                        result = Green;
                }
            }

            return result;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
